<?php

use yii\grid\GridView;
use common\helpers\Html;
use common\helpers\ImageHelper;
use common\helpers\Url;
use common\models\backend\AdminBank;

$this->title = '充值列表';
$this->params['breadcrumbs'][] = ['label' => $this->title];

?>

<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">
                    <?= $this->title; ?>
                </h3>
            </div>
            <div class="box-body table-responsive">
                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    'filterModel' => $searchModel,
                    //重新定义分页样式
                    'tableOptions' => ['class' => 'table table-hover'],
                    'columns' => [
                        [
                            'class' => 'yii\grid\SerialColumn',
                            'visible' => true, // 不显示#
                        ],
                        'order_sn',
                        [
                            'attribute' => 'username',
                            'value' => function ($model) {
                                return $model->member->username;
                            },
                        ],
                        'amount',
                        [
                            'attribute'=> 'action_type',
                            'value'=>function ($model)
                            {
                                return AdminBank::getPayType($model->action_type);
                            }
                        ],
                        'bank_name',
                        'bank_user_name',
                        'address',
                        // 'status',
                        [
                            'attribute' => 'status',
                            'format' => 'raw',
                            'value' => function($model){
                                $details = '';
                                if ($model->details) {
                                    $details = $model->details;
                                }
                                return $model->statusName . $details;
                            },
                            'filter'=> \common\models\member\Recharge::getStates(),
                        ],
                        [
                            'header' => '打款凭证',
                            'value' => function ($model) {
                                return $model->pay_img ? ImageHelper::fancyBox(Html::encode($model->pay_img)) : '未上传';
                            },
                            'filter' => false,
                            'format' => 'raw',
                        ],
                        'created_at:datetime',
                        'updated_at:datetime',
                        [
                            'attribute' => '操作',
                            'value'=>function ($model)
                            {
                              if ($model->status == 0) {
                                    $ser =  Html::a('锁定', ['recharge/suo', 'id' => $model->id, 'status' => 1], [ 'class' => 'btn btn-success btn-sm']);
                                }elseif($model->status == 1){
                                    $ser =  Html::a('取消锁定', ['recharge/suo', 'id' => $model->id, 'status' => 0], [ 'class' => 'btn btn-danger btn-sm']).'   '.Html::a('处理', ['recharge/view', 'id' => $model->id], [ 'class' => 'btn btn-success btn-sm',  'data-toggle' => 'modal','data-target' => '#ajaxModalLg',  ]);
                                }else{
                                  $ser = '<p>已处理</p>';
                                }
                                return $ser; 
                            },
                            'headerOptions'=>array(
                                      'width'=>'150',
                                      'style'=>'text-align:center',
                                ),
                            'format'=>'raw'
                        ],
                    ],
                ]); ?>
            </div>
        </div>
    </div>
<script type="text/javascript">
    $(document).on('click', '.bc', function () {
        var id = $("#abc").val();
        var url = '<?=  Url::to(['view']) ?>';
        var type = $('#type').val();
        var text = '';
        if (type == 2) {
        var url = '<?=  Url::to(['check-account']) ?>';
        }else{
        var url = '<?=  Url::to(['refuse']) ?>';
        text = $("#text").val();
        }
        $.post(url,{id:id,con:text},function(data){
        
        }); 
    });
</script>
